// Copyright 2008 Senary
// See credits.txt for details.

// This file is part of Omega VII.

// Omega VII is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Omega VII is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Omega VII.  If not, see <http://www.gnu.org/licenses/>.

#include <utility>

#include "RightPanel.h"
#include "Planet.h"
#include "Spaceship.h"

using namespace std;

RightPanel::RightPanel(void)
	: ImagePanel(make_pair(750, 64), 1, "right_frame.png"),
	_observed(0),
	_icon(make_pair(750, 160), 2, "planet.png")
{
}

RightPanel::~RightPanel(void)
{
}

// Sets the observed object
void RightPanel::setObserved(SpaceObject* observed)
{
	_observed = observed;

	// Change Icon based on the type of the observed object
	if (typeid(*_observed) == typeid(Planet)) {
		_icon.setImage("planet.png");
	} else {
		Spaceship* ss = dynamic_cast<Spaceship*>(_observed);
		if (ss != 0) {
			switch (ss->getType()) {
				case ST_YATAI_VIII:
					_icon.setImage("yataiviii.png");
					break;
				case ST_JONTH:
					_icon.setImage("jonth.png");
					break;
				case ST_CYSUS:
					_icon.setImage("cysus.png");
					break;
				case ST_METHI:
					_icon.setImage("methi.png");
					break;
			}
		}
	}
}


SpaceObject* RightPanel::getObserved()
{
	return _observed;
}

void RightPanel::createPanel()
{
	ImagePanel::createPanel();
	_icon.createPanel();
}

// Makes the panel visible
void RightPanel::display()
{
	ImagePanel::display();
	_icon.display();
}

// Hides the panel
void RightPanel::hide()
{
	ImagePanel::hide();
	_icon.hide();
}
